package ru.mcfr.oxygen.updater;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;

/**
 * Created by IntelliJ IDEA.
 * User: wstarcev
 * Date: 14.04.11
 * Time: 22:01
 * To change this template use File | Settings | File Templates.
 */
public class PropertiesContainer extends Properties{

    private String path = "";

    public PropertiesContainer(String path){
        this.path = path;
        load(path);
    }

    public void load(String path){
        File file = new File(path);
        if (file.exists() & file.isFile()){
            try {
                loadFromXML(new FileInputStream(file));
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    public void load(){load(this.path);}

    public void save(String comment){
        try {
            storeToXML(new FileOutputStream(this.path), comment);
        } catch (IOException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }
    }

    public void save(){
        save("");
    }


}
